package com.item.audrey_hepburn.util;/*/**

 _______  _______________   _________________________  __________ ____ ___  ________ 
 \      \ \_   _____/\   \ /   /\_   _____/\______   \ \______   \    |   \/  _____/ 
 /   |   \ |    __)_  \   Y   /  |    __)_  |       _/  |    |  _/    |   /   \  ___ 
/    |    \|        \  \     /   |        \ |    |   \  |    |   \    |  /\    \_\  \
\____|__  /_______  /   \___/   /_______  / |____|_  /  |______  /______/  \______  /
        \/        \/                    \/         \/          \/                 \/ 
 
 * @Auther: WD
 * @Date: 19-5-7 21:41
 * @Description: 
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionUtil {


    /**

     *@描述 获取session

     *@参数  []

     *@返回值  javax.servlet.http.HttpSession

     *@创建人  wangdong

     *@创建时间  19-5-7/下午9:42

     *@修改人和其它信息

     */
    public static HttpSession getSession() {



        HttpSession session = null;
        try {
            return getRequest().getSession();
        } catch (Exception e) {
            LoggerFactory.getLogger(SessionUtil.class).info(String.valueOf(e));
            return null;
        }

    }

    public static HttpServletRequest getRequest() {
        ServletRequestAttributes attrs =(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attrs.getRequest();
    }

    public static void main(String[] args) {
        System.out.println(SessionUtil.getSession().getId());
    }

}
